using System;
using System.Windows.Automation;
using ProdControls.Bridges;
using ProdControls.Interfaces;
using ProdLogging;

namespace ProdControls
{
    /// <summary>
    ///   Methods to work with CheckBox controls using the UI Automation framework
    /// </summary>
    public sealed class ProdCheckBox : BaseProdControl, IToggle
    {
        #region Constructors

        /// <summary>
        ///   Initializes a new instance of the ProdCheckBox class.
        /// </summary>
        /// <param name="prodWindow"> The ProdWindow that contains this control. </param>
        /// <param name="automationId"> The UI Automation element </param>
        /// <remarks>
        ///   Will attempt to match AutomationId, then ReadOnly
        /// </remarks>
        public ProdCheckBox(ProdWindow prodWindow, string automationId)
            : base(prodWindow, automationId)
        {
        }

        /// <summary>
        ///   Initializes a new instance of the ProdCheckBox class.
        /// </summary>
        /// <param name="prodWindow"> The ProdWindow that contains this control. </param>
        /// <param name="treePosition"> The index of this control in the parent windows UI control tree. </param>
        public ProdCheckBox(ProdWindow prodWindow, int treePosition)
            : base(prodWindow, treePosition)
        {
        }

        /// <summary>
        ///   Initializes a new instance of the ProdCheckBox class.
        /// </summary>
        /// <param name="controlHandle"> Window handle of the control </param>
        public ProdCheckBox( IntPtr controlHandle)
            : base( controlHandle)
        {
        }

        #endregion Constructors

        #region IToggle Members

        /// <summary>
        ///   Gets or sets the check state of the CheckBox.
        /// </summary>
        /// <value> The check state of the CheckBox. </value>
        [ProdLogging(LoggingLevels.Prod, VerbositySupport = LoggingVerbosity.Minimum)]
        public ToggleState ToggleState
        {
            get { return this.GetToggleStateHook(this); }
            set { this.SetToggleStateHook(this, value); }
        }

        /// <summary>
        ///   Changes the CheckState of checkbox to next valid CheckState
        /// </summary>
        [ProdLogging(LoggingLevels.Prod, VerbositySupport = LoggingVerbosity.Minimum)]
        public void Toggle()
        {
            this.ToggleStateHook(this);
        }

        #endregion
    }
}